package com.ardan1.client.editor;

import java.util.List;

import com.ardan1.shared.Person;
import com.google.gwt.core.client.GWT;
import com.google.gwt.editor.client.EditorError;
import com.google.gwt.editor.client.HasEditorErrors;
import com.google.gwt.editor.ui.client.ValueBoxEditorDecorator;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

public class PersonEditor extends Composite implements HasEditorErrors<Person> {

	interface PersonEditorUiBinder extends UiBinder<Widget, PersonEditor> {
    }
	
	@UiField
	ValueBoxEditorDecorator<String> nameEditor;

    @UiField
	AddressEditor addressEditor;

    @UiField
    Button saveButton;

    private static PersonEditorUiBinder uiBinder = GWT.create(PersonEditorUiBinder.class);
    
    public PersonEditor() {
    	 initWidget(uiBinder.createAndBindUi(this));
    }

	@Override
	public void showErrors(List<EditorError> errors) {
		GWT.log("Wow" + errors);
	}
	
    public HandlerRegistration addSaveClickHandler(ClickHandler handler) {
        return saveButton.addClickHandler(handler);
    }

}
